parser grammar Anasint;

options {
  language = Java;
  output = AST;
  tokenVocab = Analex;
  ASTLabelType = Arbolito;
  backtrack = true;
}

tokens {
  INSTRS;
}

instrucciones: (action SEMICOLON!)* EOF!;

action: exp | asignacion | def_function;

exp : exp_mult ((PLUS | MINUS)^ exp_mult)* ;
exp_mult : exp_base ((ASTERISK | DIV)^ exp_base)* ;
exp_base : numero | ID | LPARENTHESIS! exp RPARENTHESIS!;

numero: (MINUS)? (NUM_INTEGER | NUM_REAL);


asignacion: ID ASSIGN^ exp;
def_function: ID LPARENTHESIS! (ID | exp) RPARENTHESIS! ASSIGN^ exp;